package com.boot.cluster.model;

import com.boot.cluster.enums.MessageType;
import org.jgroups.Address;

import java.io.Serializable;
import java.util.UUID;

public class MessageInfo<T> implements Serializable {
	private static final long serialVersionUID = -4012816810325644897L;
	private String id;
	private Address src;
	private T msg;
	private MessageType type;

	public MessageInfo() {
	}

	public MessageInfo(Address src, T msg) {
		this.src = src;
		this.msg = msg;
		this.id=UUID.randomUUID().toString().replaceAll("-", "");
	}

	public MessageInfo(Address src, T msg, MessageType type) {
		this.src = src;
		this.msg = msg;
		this.type =type;
		this.id=UUID.randomUUID().toString().replaceAll("-", "");
	}

	public Address getSrc() {
		return this.src;
	}

	public void setSrc(Address src) {
		this.src = src;
	}

	public T getMsg() {
		return this.msg;
	}

	public void setMsg(T msg) {
		this.msg = msg;
	}

	public String getId() {
		return this.id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public MessageType getType() {
		return this.type;
	}

	public void setType(MessageType type) {
		this.type = type;
	}

}
